import { GCellRenderer } from "../../../../com/mui/controls/GCellRenderer";
import { ObjCreate } from "../common/ObjCreate";
import { ImagesConst } from "../../resource/ImagesConst";
import { BaseItem } from "../common/BaseItem";
import { ItemInfo } from "../../resource/info/ItemInfo";
import { ItemData } from "../../resource/info/ItemData";
import { Dispatcher } from "../../../mvc/core/Dispatcher";
import { DataEvent } from "../../events/DataEvent";
import { EventName } from "../../mvc/EventName";
import { FilterConst } from "../../../component/gconst/FilterConst";
type int = number;
//class ItemRenderer
    
    export  class ItemRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            return;
        }

        protected /* override */ configUI(): void
        {
            ObjCreate.createBitmap(ImagesConst.PackItemBg, 3, 3, this);
            this._item = new BaseItem();
            this._item.setSize(32, 32);
            this._item.move(6, 6);
            this._item.isDropAble = false;
            addChild(this._item);
            addEventListener(flash.events.MouseEvent.CLICK, this.onItemClickHandler);
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            var loc1=arg1 as ItemInfo;
            if (arg1) 
            {
                this._code = loc1.item.code;
                this._item.itemData = new ItemData(this._code);
            }
            else 
            {
                this._item.itemData = null;
            }
            return;
        }

        protected onItemClickHandler(arg1: Object /* flash.events.MouseEvent */): void
        {
            if (this._item.itemData) 
            {
                Dispatcher.dispatchEvent(new DataEvent(EventName.MarketSeekBuyItemCode, this._code));
            }
            return;
        }

        public /* override */ set selected(arg1: Boolean)
        {
            this._item.filters = [];
            super.selected = arg1;
            if (arg1) 
            {
                this._item.filters = [FilterConst.itemChooseFilter];
            }
            return;
        }

        protected /* var */_item: BaseItem;

        protected /* var */_code: int;
    }
